package handlers

import (
	"art-management-system/models"
	"github.com/gin-gonic/gin"
	"strconv"
)

func ListPicture(c *gin.Context) {
	page, _ := strconv.Atoi(c.Query("page"))
	size, _ := strconv.Atoi(c.Query("size"))
	offset := (page - 1) * size

	var count int64
	models.DB.Model(&models.Picture{}).Count(&count)

	var data []models.Picture
	models.DB.Offset(offset).Limit(size).Find(&data)

	c.JSON(200, gin.H{
		"code":  500,
		"msg":   "success",
		"data":  data,
		"count": count,
	})
	return

}
